package web

import (
	"strings"
	"net/http"
)

//
// 设置视图
//
func SetControllerPath(url string, controller ControllerInterface) (ok bool) {
	ok = false

	if !strings.HasPrefix(url, "/") {
		url = "/" + url
	}

	controllerMaps[url] = controller
	ok = true
	return
}

//
// 视图请求处理
//
func serverControllerRouter(url string, response http.ResponseWriter, request *http.Request) (ok bool) {
	ok = false

	h, e := controllerMaps[url]
	if e == true {
		h.Handler(response, request)
		ok = true
		return
	}

	return
}
